package com.idealighter.game.dao.logger.mapper;

import com.idealighter.game.dao.logger.po.Loginlog;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface LoginlogMapper {

    @Select("select exists(SELECT DISTINCT t.table_name FROM information_schema.TABLES t WHERE  t.table_schema = (SELECT DATABASE()) and  t.table_name = 'loginlog${IPTime}')")
    public int existTable(@Param("IPTime") String date);


    @Select({ "<script>",
            "SELECT",
            "*",
            "FROM",
            "loginlog${IPTime}",
            "<where>",
            "isPlayer = 1",
            "<if test = 'IP !=null'>and ip = #{IP} </if>",
            "</where>",
            "order by time desc, id desc",
            "</script>" })
    List<Loginlog> selectByPage(@Param("IP") String IP,
                                @Param("IPTime") String date);
}
